package com.jifeng.api.crud.controller;

import java.util.Arrays;
import java.util.Map;

import com.jifeng.api.utils.PageUtils;
import com.jifeng.api.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jifeng.api.crud.entity.VwDeviceUserEntity;
import com.jifeng.api.crud.service.VwDeviceUserService;



/**
 * VIEW
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-10-13 13:00:14
 */
@RestController
@RequestMapping("crud/deviceuser")
public class VwDeviceUserController {
    @Autowired
    private VwDeviceUserService vwDeviceUserService;

    /**
     * 查询设备列表
     */
    @GetMapping("/pc/list")
    public R list(@RequestParam Map<String, Object> params){
        R rs = vwDeviceUserService.queryPage(params);

        return rs;
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		VwDeviceUserEntity vwDeviceUser = vwDeviceUserService.getById(id);

        return R.ok().put("vwDeviceUser", vwDeviceUser);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody VwDeviceUserEntity vwDeviceUser){
		vwDeviceUserService.save(vwDeviceUser);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody VwDeviceUserEntity vwDeviceUser){
		vwDeviceUserService.updateById(vwDeviceUser);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		vwDeviceUserService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
